#ifndef DDAS_DB_HANDLER_HPP
#define DDAS_DB_HANDLER_HPP

extern "C"
{
	#include "lip.h"
}

#include "ddas_definitions.h"
#include "DDAS_Client_Result_Data.hpp"

///This class serves as a database interface for many of the DDAS components
class DDAS_DB_Handler
{
	public:

	DDAS_DB_Handler();

	~DDAS_DB_Handler();



        unsigned long DDAS_DB_Handler::getFinalWorkUnitIterationForCurrentWorkgenCycle( int job_id, long starting_value );

	unsigned long DDAS_DB_Handler::calculateTotalWorkunitsRequiredForJob( int job_id );

        unsigned long DDAS_DB_Handler::getTotalWorkunitsRequiredForJob( int job_id );

        unsigned long DDAS_DB_Handler::getCurrentWorkgenIteration( int job_id );

	int DDAS_DB_Handler::getNewProblemIDs( int** job_ids );
	
	int DDAS_DB_Handler::getQuorumSize( int job_id );

	int DDAS_DB_Handler::setAllWorkCompleteForJob( int job_id );

	int DDAS_DB_Handler::hasAllWorkBeenCreatedForJob( int job_id, long current_iteration );

	int DDAS_DB_Handler::setCurrentWorkgenIteration( int job_id, long current_iteration );

	int DDAS_DB_Handler::setTotalWorkunitsRequiredForJob( int job_id, unsigned long iteration );

	int DDAS_DB_Handler::initVarsFrom_ddas_problem(int pid, long* uid, long* numX, long* numY, long* numRows, long* numResults, long* quorumSize);

	int DDAS_DB_Handler::initWorkgenVars( int job_id, long* uid, long* numX, long* numY, long* numRows, long* numResults, long* quorumSize, verylong* workunit_count, verylong* workunit_stride, verylong* total_combinations );

	int DDAS_DB_Handler::markJobAsComplete( int job_id );

	int DDAS_DB_Handler::getUnprocessedCompleteJobs( int* size, int** completed_jobs );

	int DDAS_DB_Handler::getNumResults( int job_id );

	int DDAS_DB_Handler::getIndependentVarCountFromJob( int job_id );

	int DDAS_DB_Handler::getIndependentVarCountFromResult( int result_id );

	int DDAS_DB_Handler::getTopNResults( int job_id, int num_results, DDAS_Client_Result_Data* results );

	int DDAS_DB_Handler::getWorkCushion( int job_id );
};

#endif
